package com.soonfor.evaluate.presenter;
import android.content.Context;
import com.google.gson.Gson;
import com.soonfor.evaluate.bean.EvaluateListDetailBean;
import com.soonfor.evaluate.http.api.Request;
import com.soonfor.evaluate.http.httptools.AsyncUtils;
import com.soonfor.evaluate.activity.Evaluate_IToCustomersDetailActivity;
import com.soonfor.evaluate.base.IEvalBasePresenter;

/**
 * 作者：DC-DingYG on 2018-10-18 11:29
 * 邮箱：dingyg012655@126.com
 */
public class Evaluate_IToCustomersDetailPresenter implements IEvalBasePresenter, AsyncUtils.AsyncCallback {

    private Evaluate_IToCustomersDetailActivity view;
    private Context mContext;

    public Evaluate_IToCustomersDetailPresenter(Evaluate_IToCustomersDetailActivity view) {
        this.view = view;
    }

    public void getDetail(Context mContext, int sousetype, String souseId) {
        this.mContext = mContext;
        Request.Evaluate.getEvaluateDetailInfo(mContext,1, sousetype, souseId, Request.Evaluate.GET_EVALUATE_ITOCUSTOMERINFO,this);
    }

    @Override
    public void success(int requestCode, String data) {
        final Gson gson = new Gson();
        switch (requestCode) {
            case Request.Evaluate.GET_EVALUATE_ITOCUSTOMERINFO:
                try {
                    EvaluateListDetailBean detailBean = gson.fromJson(data, EvaluateListDetailBean.class);
                    view.showViewByData(detailBean, null);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
        }
    }

    @Override
    public void fail(int requestCode, int statusCode, String data, String msg) {
        switch (requestCode) {
            case Request.Evaluate.GET_EVALUATE_ITOCUSTOMERINFO:
                view.showNoDataHint(msg);
                break;
        }
    }
}